Core.Test.registerTest({
	group: "dao",
	name: "Core.Storage.Configuration",
	
	_should: {
		error: {
			"Should error on unresolved conflicted override (without resolveOverrideConflict())": true,
			"Should error on unresolved conflicted override (false on resolveOverrideConflict())": true
		}
	},
	
	before: function() {
		this.conf = new Core.Storage.Configuration();
	},
	
	"Should override once (same priority, one object)": function() {
		this.conf.override("prop", 10, this, 20);
		Assert.equal(10, this.conf.get("prop"));
	},
	
	"Should override many times (same priority, one object)": function() {
		this.conf.override("prop", 10, this, 20);
		this.conf.override("prop", 15, this, 20);
		this.conf.override("prop", 25, this, 20);
		
		Assert.equal(25, this.conf.get("prop"));
	},
	
	"Should successfully override when resolved conflicted override (same priority, many objects)": function() {
		var stub = { resolveOverrideConflict: function() { return true; }};
		
		this.conf.override("prop", 10, stub, 20);
		this.conf.override("prop", 15, this, 20);

		Assert.equal(15, this.conf.get("prop"));
	},
	
	"Should error on unresolved conflicted override (without resolveOverrideConflict())": function() {
		var stub = {};
		
		this.conf.override("prop", 10, stub, 20);
		this.conf.override("prop", 15, this, 20);
	},
	
	"Should error on unresolved conflicted override (false on resolveOverrideConflict())": function() {
		var stub = { resolveOverrideConflict: function() { return false; }};
		
		this.conf.override("prop", 10, stub, 20);
		this.conf.override("prop", 15, this, 20);
	},
	
	"Should override and hide values with the lower priority (different priorities, same object)": function() {
		this.conf.override("prop", 15, this, 20);
		this.conf.override("prop", 20, this, 15);
		this.conf.override("prop", 25, this, 10);
		
		Assert.equal(25, this.conf.get("prop"));
	},
	
	"Should override without any conflicts (different priorities, many objects)": function() {
		this.conf.override("prop", 15, this, 20);
		this.conf.override("prop", 20, window, 15);
		this.conf.override("prop", 25, Core.Storage, 10);
		
		Assert.equal(25, this.conf.get("prop"));
	},
	
	"Should clear the owned override (same priority)": function() {
		this.conf.override("prop", 15, this, 20);
		this.conf.clearOverride("prop", this, 20);
		
		Assert.equal(undefined, this.conf.get("prop"));
	},
	
	"Should do nothing when clearing not owned override (same priority)": function() {
		this.conf.override("prop", 15, this, 20);
		this.conf.clearOverride("prop", window, 20);
		
		Assert.equal(15, this.conf.get("prop"));
	},
	
	"Should clear the top visible owned override": function() {
		debug = true;
		this.conf.override("prop", 15, this, 20);
		this.conf.override("prop", 20, this, 15);

		this.conf.clearOverride("prop", this, 15);
		Assert.equal(15, this.conf.get("prop"));
	},
	
	"Should clear the not visible owned override": function() {
		this.conf.override("prop", 15, this, 20);
		this.conf.override("prop", 20, this, 15);
		this.conf.override("prop", 10, this, 10);
		
		this.conf.clearOverride("prop", this, 15);
		Assert.equal(10, this.conf.get("prop"));
		
		this.conf.clearOverride("prop", this, 10);
		Assert.equal(15, this.conf.get("prop"));
	}
});